package com.fly.web;

import com.fly.base.Result;
import com.fly.base.ResultGenerator;
import com.fly.domain.model.ScResource;
import com.fly.domain.service.ScResourceService;
import com.fly.util.SidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.fly.util.SidService.Biz.RESOURCE;

/**
 * Created by frinder on 2018/4/3.
 */
@RestController
@RequestMapping("/myScResource")
public class MyScResourceController {

    @Resource
    private ScResourceService scResourceService;

    @Autowired
    private SidService sidService;

    @PostMapping("/add")
    public Result add(ScResource scResource) {
        scResource.setSid(sidService.getSid(RESOURCE));
        scResourceService.save(scResource);
        return ResultGenerator.genSuccessResult();
    }

}
